package com.example.himalaya.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

/**
 * Fragment片段父类
 */
public abstract class BaseFragment extends Fragment {
    private View mRootView;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        //父类根据子类Fragment片段返回的view创建显示视图
        mRootView = onSubViewLoaded(inflater,container);
        return mRootView;
    }

    /**
     * 获得子类Fragment片段要显示的视图
     * @param inflater 父类Fragment片段提供的加载器
     * @param container 父类Fragment片段提供的容器，用于视图的测绘显示
     * @return 子类Fragment片段要显示的视图
     */
    protected abstract View onSubViewLoaded(LayoutInflater inflater, ViewGroup container);

}
